package com.ryan;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

public class Bean {

	private int type = 1;
	private CpInfo cpInfo;
	private UnicomConsume[] unicomconsume;
	private String channel_code;
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public CpInfo getCpInfo() {
		return cpInfo;
	}
	public void setCpInfo(CpInfo cpInfo) {
		this.cpInfo = cpInfo;
	}
	public UnicomConsume[] getUnicomconsume() {
		return unicomconsume;
	}
	public void setUnicomconsume(UnicomConsume[] unicomconsume) {
		this.unicomconsume = unicomconsume;
	}
	public String getChannel_code() {
		return channel_code;
	}
	public void setChannel_code(String channel_code) {
		this.channel_code = channel_code;
	}
	
	public static void main(String[] args) throws Exception{
		
		BufferedReader reader = null;
		StringBuffer sb = new StringBuffer();
		try{
			String tmp = null;
			reader = new BufferedReader(new InputStreamReader(new FileInputStream("D:/android/20131128/UnicomConsum.uwc"), "utf-8"));
			while((tmp = reader.readLine()) != null){
				sb.append(tmp);
			}
		}catch(Exception e){}
		
		JSONObject unicomObj = new JSONObject(sb.toString());
		System.out.println(unicomObj.get("type"));
		
		
		JSONObject json = new JSONObject();
		json.put("type", "0");
		json.put("channel_code", "00012243");
		json.put("apk_versioname", "1");
		json.put("apk_versioncode", "1.0.1");
		json.put("apk_package", "com.fox.gcllk.lt");
		
		JSONObject cpInfoJson = new JSONObject();
		cpInfoJson.put("app_id", "90241724320121109164036055100");
		cpInfoJson.put("cp_code", "902417243");
		cpInfoJson.put("cp_id", "86000504");
		cpInfoJson.put("telephone", "021-61588876");
		cpInfoJson.put("app_name", "联通计费测试");
		json.put("cpinfo", cpInfoJson);
		
		JSONArray arrs = new JSONArray();
		JSONObject object = null;
		for(int i=1;i<=200;i++){
			object = new JSONObject();
			String tmp = "";
			if(i < 10){
				tmp = "00"+String.valueOf(i);
			}else if(i<100 && i>= 10){
				tmp = "0" + String.valueOf(i);
			}else{
				tmp = String.valueOf(i);
			}
			object.put("number",tmp);
			object.put("vac_code","131111015005");
			object.put("custom_code","90241724320131111153953529300001");
			object.put("prop_name","联通测试计费点1角");
			object.put("pay_money","10");
			object.put("vac_mode","1");
			arrs.put(object);
		}
		json.put("unicomconsume", arrs);
		
		System.out.println(json.toString());
	}
}

class CpInfo{
	private String app_id;
	private String cp_code;
	private String cp_id;
	private String cp_name;
	private String telephone;
	private String app_name;
	private String version_name;
	private String version_code;
	public String getApp_id() {
		return app_id;
	}
	public void setApp_id(String app_id) {
		this.app_id = app_id;
	}
	public String getCp_code() {
		return cp_code;
	}
	public void setCp_code(String cp_code) {
		this.cp_code = cp_code;
	}
	public String getCp_id() {
		return cp_id;
	}
	public void setCp_id(String cp_id) {
		this.cp_id = cp_id;
	}
	public String getCp_name() {
		return cp_name;
	}
	public void setCp_name(String cp_name) {
		this.cp_name = cp_name;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getApp_name() {
		return app_name;
	}
	public void setApp_name(String app_name) {
		this.app_name = app_name;
	}
	public String getVersion_name() {
		return version_name;
	}
	public void setVersion_name(String version_name) {
		this.version_name = version_name;
	}
	public String getVersion_code() {
		return version_code;
	}
	public void setVersion_code(String version_code) {
		this.version_code = version_code;
	}
}

class UnicomConsume{
	private String number;
	private String vac_code;
	private String custom_code;
	private String prop_name;
	private String pay_money;
	private int vac_mode;
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	public String getVac_code() {
		return vac_code;
	}
	public void setVac_code(String vac_code) {
		this.vac_code = vac_code;
	}
	public String getCustom_code() {
		return custom_code;
	}
	public void setCustom_code(String custom_code) {
		this.custom_code = custom_code;
	}
	public String getProp_name() {
		return prop_name;
	}
	public void setProp_name(String prop_name) {
		this.prop_name = prop_name;
	}
	public String getPay_money() {
		return pay_money;
	}
	public void setPay_money(String pay_money) {
		this.pay_money = pay_money;
	}
	public int getVac_mode() {
		return vac_mode;
	}
	public void setVac_mode(int vac_mode) {
		this.vac_mode = vac_mode;
	}
}
